package com.afei.oid;

import java.util.LinkedList;
import java.util.Queue;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;
import android.view.MotionEvent;

public class PlayTheard {
	private static final String TAG = "TheardProxy";
	private static final int LATER_SEND_MESSAGE = 1001;
	private HandlerThread mPlayThread;
	private PlayHandle	 mMyHandle;
	private GetPlayInfo mGetPlayInfo;
	private Context mContext;
	private String mFileNamePath;
	public PlayTheard(Context context,int pagecount,String strfile,int offset,Handler ui)
	{
		mContext = context;
		mPlayThread = new HandlerThread("Mp3Play_handler_thread");  
 		mPlayThread.start(); 
 		mFileNamePath = strfile;
 		mMyHandle = new PlayHandle(mPlayThread.getLooper(),ui);  
 		mMyHandle.InitFile(strfile,offset);
	}
	public void SendPlayAudio(int index)
	{
		Message msg = Message.obtain(mMyHandle,EbookConstants.TouchEvent.EVENT_PLAYAUDIO.ordinal());
		msg.arg1 = index;
		msg.sendToTarget();
	}
	public void SendTouchEvent(int x,int y)
	{
		Message msg = Message.obtain(mMyHandle,EbookConstants.TouchEvent.EVENT_TOUCH.ordinal());
		msg.arg1 = x;
		msg.arg2 = y;
		msg.sendToTarget();
	}
	public void UpdatePageNumber(int num)
	{
		Message msg = Message.obtain(mMyHandle,EbookConstants.TouchEvent.EVENT_UPDATEPAGE.ordinal());
		msg.arg1 = num;
		msg.sendToTarget();
	}
	public void SendAutoEvent(EbookConstants.TouchEvent event)
	{
		Message msg = Message.obtain(mMyHandle,event.ordinal());
		msg.sendToTarget();
	}
}
